#include <iostream>

using namespace std;

bool fruits[200010];
int ids[200010];

int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	
	int n;
	int last;
	
	scanf("%d",&n);
	last = n;
	
	for (int i = 1;i <= n;i++)
	{
		scanf("%d",&fruits[i]);
		ids[i] = i;
	}
	
	while (last)
	{
		bool lo;
		bool f = true;
		for (int i = 1;i <= n;i++)
		{
			if (ids[i] && (fruits[i] != lo))
			{
				printf("%d ",ids[i]);
				ids[i] = 0;
				lo = fruits[i];
				last--;
				f = false;
			}
			else if (ids[i] && f)
			{
				printf("%d ",ids[i]);
				ids[i] = 0;
				lo = fruits[i];
				last--;
				f = false;
			}
		}
		cout << endl;
	}
	
	return 0;
}
